package com.ybwh.springboot2.okadmin.sys.service.impl;

import com.github.pagehelper.Page;
import com.google.common.base.Preconditions;
import com.ybwh.springboot2.common.Pagination;
import com.ybwh.springboot2.okadmin.sys.dao.SysUserAccountMapper;
import com.ybwh.springboot2.okadmin.sys.model.po.SysUserAccount;
import com.ybwh.springboot2.okadmin.sys.model.vo.user.UserAccountPageParam;
import com.ybwh.springboot2.okadmin.sys.model.vo.user.UserAccountPageVO;
import com.ybwh.springboot2.okadmin.sys.service.SysUserAccountService;
import com.ybwh.springboot2.util.ConvertUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 账号表服务接口实现类
 * </p>
 *
 * @author Fan Beibei
 * @version V1.0
 * @since 2023-04-08 19:57:22
 */
@Slf4j
@Service
public class SysUserAccountServiceImpl implements SysUserAccountService {
    @Resource
    private SysUserAccountMapper sysUserAccountMapper;


//------------以上是生成代码-----------------------------------------------------------------------------------------------------------------

    @Override
    public SysUserAccount selectById(Long id) {
        return sysUserAccountMapper.getById(id);
    }

    @Override
    public Pagination<UserAccountPageVO> pageList(UserAccountPageParam param) {
        Preconditions.checkArgument(null != param);

        Page<SysUserAccount> page = sysUserAccountMapper.selectByPage(param, param.getPageNum(), param.getPageSize());
        return ConvertUtils.page2Pagination(page, new ConvertUtils.Convertor<SysUserAccount, UserAccountPageVO>() {
            @Override
            public UserAccountPageVO convert(SysUserAccount sysUserAccount) {
                UserAccountPageVO vo = new UserAccountPageVO();
                BeanUtils.copyProperties(sysUserAccount, vo);
                return vo;
            }
        });
    }


    @Override
    public SysUserAccount queryByAccount(String account) {

        return sysUserAccountMapper.selectByAccount(account);
    }


}
